﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
///Permission 的摘要说明
/// </summary>
public class Permission
{
	public Permission()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    public Permission(int gid)
    {
        GetData gd = new GetData();
        groups g = gd.GetOneGroup(gid);
        if(g!=null)
        {
            isExist = true;
            this.gid = gid;
            this.name = g.name;
            this.color = g.color;
            this.awaccess = g.allowaccess;
            this.awpost = g.allowpost;
            this.awreply = g.allowreply;
            this.awedit = g.allowedit;
            this.awdel = g.allowdelete;
            this.awmag = g.allowmanage;
        }
        else
        {
            isExist = false;
        }

    }

    public int gid;
    public string name;
    public string color;
    public int awaccess;
    public int awpost;
    public int awreply;
    public int awedit;
    public int awdel;
    public int awmag;
    public bool isExist;

    public void Publish()
    {
        try
        {
            SaveData.NewGroup(this);
        }
        catch (System.Exception ex)
        {
        	
        }
    }

    public void Update()
    {
        try
        {
            SaveData.UpdateGroup(this);
        }
        catch (System.Exception ex)
        {
        	
        }
    }
}